package com20230224;

import java.util.Arrays;

public class PhoenixTest {


    public static void sort(Phoenix[] phoenixs ){

        for (int i = 0; i < phoenixs.length - 1; i++) {
            for (int j = 0; j < phoenixs.length - 1 - i; j++) {
                boolean b = ( (phoenixs[j].getAge() == phoenixs[j+1].getAge()) && phoenixs[j].getGender() > phoenixs[j+1].getGender() );
                if (phoenixs[j].getAge() > phoenixs[j+1].getAge()  || b){
                    Phoenix temp = phoenixs[j];
                    phoenixs[j] = phoenixs[j+1];
                    phoenixs[j+1] = temp;
                }
            }

        }
    }
    public static void main(String[] args) {
        Phoenix[] phoenixs = new Phoenix[ 5 ];
        phoenixs[ 0 ] = new Phoenix( "凤凰卫士" , 150 , '男' );
        phoenixs[ 1 ] = new Phoenix( "凤凰大侠" , 200 , '男' );
        phoenixs[ 2 ] = new Phoenix( "凤凰宝贝" , 120 , '男' );
        phoenixs[ 3 ] = new Phoenix( "凤凰勇士" , 200 , '女' );
        phoenixs[ 4 ] = new Phoenix( "凤凰天使" , 100 , '女' );

        sort(phoenixs);
        System.out.println(Arrays.toString(phoenixs));
        for (int i = 0; i < phoenixs.length;i++) {
            System.out.println(phoenixs[i] );

        }
    }
}
